<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-05 15:16:04
 * @LastEditTime: 2020-03-24 10:04:28
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/Sortable.js"></script>
    <script type="text/javascript" src="../script/vuedraggable.umd.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <script type="text/javascript" src="../script/db.js"></script>
    <style type="text/css">
        .head_v {
            height: 40px !important;
            padding-top: 0 !important;
        }

        .body-no-bottom_v {
            height: calc(100% - 40px) !important;
        }

        .content {
            /* background: red !important; */
            background: url(../image/goodsShelves/bg.png) no-repeat;
            background-size: 100% 100%;
        }

        .row-1 {
            padding: 10px 0;
        }

        .row-2 {
            margin-bottom: 10px;
            padding-bottom: 10px;
            border-bottom: 1px solid #ebedf0;
        }

        .row-2>div {
            position: relative;
        }

        .ch {
            width: 60px;
            height: 45px;
            text-align: center;
            border-right: 1px solid #cd1b21;

        }

        .num {
            color: #cd1b21;
            height: 27px;
            font-weight: 700;
            font-size: 14px;
            line-height: 27px;
        }

        /* .ch-p {
            position: absolute;
            top: 0;
            left: 60px;
            right: 0;
            bottom: 0;
            white-space: nowrap;
        } */

        .ch-p-l {
            white-space: nowrap;
            overflow: hidden;
            /* padding-top: 10px; */
        }

        .ch-p-n {
            display: inline-block;
            font-size: 0;
            text-align: center;
            /* min-width: 60px; */
            position: relative;
        }

        .ch-p-n * {
            vertical-align: middle;
            font-size: 14px;
        }

        .delete {
            position: absolute;
            top: -10px;
            left: 50%;
            margin-left: -28px;
            width: 20px;
            height: 20px;
            border-radius: 10px;
            overflow: hidden;
            background: #fff;
            line-height: 20px;
            text-align: center;
        }

        .delete:active {
            background: #cd1b21;
        }

        .delete:active i {
            color: #fff !important;
        }

        .cb-b {
            padding: 4px;
            display: inline-block;
            background: #fff;
            border: 1px solid rgba(149, 149, 149, 0.7);
            margin-bottom: 3px;
        }

        .cb {
            width: 22px;
            height: 22px;

        }

        .cb-n {
            display: inline-block;
            width: 30px;
            height: 11px;
            background-image: url(../image/goodsShelves/mp.png);
            background-repeat: no-repeat;
            background-size: 100% 100%;
            /* background: #898989; */
            color: #b91627;
            text-shadow: 0px 0px 15px #b91627;
            font-size: 12px;
            line-height: 11px;
            /* margin-bottom: 13px; */
        }

        .cb-n span {
            display: inline-block;
            transform: scale(0.8);
        }

        .row-name {
            display: inline-block;
            width: 180px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            vertical-align: middle;
        }

        .van-cell__title {
            max-width: none;
        }

        .van-cell__value {
            text-align: right;
        }

        .bg {
            background-image: url(../image/goodsShelves/hj.png);
            background-repeat: no-repeat;
            background-size: 100% 100%;
            padding: 0 18px 0 18px;
            /* overflow: hidden; */
            position: absolute;
            left: 10px;
            bottom: 10px;
            right: 40px;
        }

        .c {
            height: 46px;
            background-image: url(../image/goodsShelves/bz.png);
            background-repeat: no-repeat;
            background-position: bottom left;
            background-size: 100% 20px;
            margin-left: -12px;
            margin-right: -12px;
            margin-bottom: 10px;
            /* overflow: hidden; */
            position: relative;
        }

        .total {
            padding-left: 15px;
        }

        .total span {
            font-size: 13px;
            vertical-align: middle;
        }

        .total-num {
            width: 20px;
            height: 20px;
            color: #fff;
            background: #b91627;
            display: inline-block;
            text-align: center;
            border-radius: 3px;
            margin-right: 5px;
        }

        .left {
            width: 100px;
            height: 100%;
            position: relative;
        }

        .slide-bottom {
            position: absolute;
            left: 0;
            bottom: 0;
            padding: 8px;
            width: 100%;
        }

        .van-button {
            padding: 0;
        }

        .center {
            position: absolute;
            top: 0;
            left: 100px;
            right: 80px;
            height: 100%;
            padding: 10px 40px 10px 10px;
            overflow-y: scroll;
            background: #fff;
            overflow-x: hidden;
        }

        .right {
            position: absolute;
            right: 0;
            top: 0;
            width: 80px;
            height: 100%;
        }

        .van-sidebar {
            width: 80px;
        }

        .van-sidebar-item {
            padding: 10px 12px 10px 8px;
            font-size: 13px;
        }

        .recycle {
            display: inline-block;
            width: 100%;
            text-align: center;
            padding: 15px 0;
            /* box-shadow: 0 0 5px rgb(200, 198, 198); */
        }

        .left-tab>div {
            /* height: 40px; */
            /* line-height: 40px; */
            font-size: 13px;
            padding: 8px 5px 8px 20px;
            /* padding-left: 20px; */
            border-left: 3px solid transparent;
            position: relative;
        }
        .jz{
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            padding-left: 20px;
            width: 100%;
        }

        .left-tab>div.on {
            color: #cd1b21;
            border-color: #cd1b21;
            background: #fff;
        }

        /* .right-tool {
            position: absolute;
            right: 0;
            top: 30px;
            width: 26px;
            height: 30px;
            text-align: center;
            line-height: 32px;
            background: rgba(0, 0, 0, .7);
        } */

        .right-page {
            background: #fff;
            width: 80px;
            height: 120px;
            position: fixed;
            z-index: 99999999;
            right: -80px;
            top: 40px;
            transition: all .4s;
            box-shadow: 0 0 5px rgb(200, 198, 198);
        }

        .right-page-show {
            right: 0;
            border-color: #fff;
        }

        .arrow {
            left: -12px;
            top: 50%;
            margin-top: -26px;
            position: absolute;
            width: 24px;
        }

        .arrow img {
            width: 12px;
            transform: rotate(180deg)
        }

        .van-dialog {
            width: 320px;
        }

        .row-total {
            position: absolute;
            right: -38px;
            top: 10px;
            width: 30px;
            font-size: 12px;
            text-align: center;
            font-weight: 700;
        }

        .row-total .n {
            width: 20px;
            height: 20px;
            line-height: 20px;
            border-radius: 4px;
            background: #cd1b21;
            color: #fff;
            margin: 0 auto;
        }

        .hj {
            position: absolute;
            right: -32px;
            top: -20px;
            font-size: 12px;
            text-align: center;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="init-full">
            <van-nav-bar class="head" :class="systemType=='ios'?'head_v':''" title="货架" left-arrow
                @click-left="onClickLeft">
                <div slot="right" class="head-right">
                    <span @click="toggleSort" v-show="dataList.length">{{showSort?'完成':'编辑'}}</span>
                    <span @click="showSearch = true;">
                        <img src="../image/search.png" />
                    </span>
                </div>
            </van-nav-bar>
            <div class="body-no-bottom" :class="systemType=='ios'?'body-no-bottom_v':''">
                <div class="content">
                    <div class="left">
                        <div class="left-tab">
                            <div v-for="(row1,index1) in dataList" class="tab-row" :index="index1"
                                :class="tabActive == index1?'on':''" @click="changeTab(index1)">{{row1.HJName}}</div>
                        </div>


                        <div class="slide-bottom">
                            <div>
                                <van-button size="small" type="primary" block @click="addNewHJ">新增货架</van-button>
                            </div>
                        </div>
                    </div>
                    <div class="center">
                        <div class="bg" v-if="dataList.length">
                            <div class="c" v-for="(row2,index2) in dataList[tabActive].node">
                                <div class="ch-p">
                                    <draggable v-model="row2.node"
                                        :options='{group: "menu",draggable:".disabled-draggable"}'
                                        @start="startMoveDraggable" @end="endMoveDraggable" :move="MoveDraggable"
                                        class="ch-p-l">
                                        <div class="ch-p-n" :class="showSort?'disabled-draggable':''"
                                            v-for="(row3,index3) in row2.node"
                                            @click="intoDetail2(row3,row2,dataList[tabActive],index2,index3)"
                                            :style="{width: 100/row2.node.length + '%' }">
                                            <div class="cb-b">
                                                <img class="cb" :src="'http:' + row3.CXPath" />
                                            </div>
                                            </br>
                                            <div class="cb-n"><span>{{getTotalNum(row3)}}</span></div>


                                        </div>
                                    </draggable>

                                </div>

                                <div class="row-total" @click="intoDetail1(row2,dataList[tabActive],index2)">
                                    <!-- <div>合计</div> -->
                                    <div style="text-align: center;">
                                        <div class="n">{{getRowTotal(row2)}}</div>
                                    </div>

                                    <div style="color: #969799">{{row2.Explain || ''}}</div>
                                </div>


                            </div>
                            <div class="hj">合计</div>
                        </div>
                        <div class="bg" v-if="!dataList.length">
                            <div class="c">

                            </div>
                            <div class="c">

                            </div>
                            <div class="c">

                            </div>
                            <div class="c">

                            </div>
                            <div class="c">

                            </div>
                        </div>

                    </div>
                    <div class="right">
                        <div style="text-align: center;margin-bottom: 15px;" v-if="showSort">
                            <div style="margin-bottom: 15px;">
                                <draggable v-model="deleteArray"
                                    :options='{group: "menu",draggable:".disabled-draggable"}'
                                    @start="startMoveDraggable" style="height: 60px;overflow: hidden;">
                                    <div v-for="(row,index) in deleteArray">
                                        <div class="recycle">
                                            <img src="../image/goodsShelves/g13.png" style="width: 55%;" />
                                        </div>
                                    </div>

                                </draggable>
                            </div>
                            <div style="padding: 0 6px;">
                                <div
                                    style="text-align: center;border: 1px dashed #d0d0d0;height: 50px;line-height: 44px;">
                                    <div v-show="!carArray.length">
                                        <van-icon name="add-o" size="36px" color="#d0d0d0"
                                            style="vertical-align: middle;display: inline-block;" @click="addNew">
                                        </van-icon>
                                        <div style="color: #cd1b21;font-size:12px;">选择车型</div>
                                    </div>
                                    <div v-show="carArray.length">
                                        <draggable v-model="carArray" :options='{group: "menu"}'
                                            @start="startMoveDraggable">
                                            <div v-for="(row,index) in carArray" style="display: inline-block;">
                                                <img style="width: 28px;height:28px;" :src="'http:' + row.CXPath" />
                                            </div>
                                        </draggable>
                                    </div>
                                </div>
                            </div>


                        </div>


                        <div class="slide-bottom">
                            <div style="text-align: center;margin-bottom: 10px;font-size: 12px;"
                                @click="openCheckedList">
                                <span>合计补货</span>
                                <span style="color: #b91627">{{getBHCount()}}</span>
                            </div>

                            <div>
                                <van-button :disabled="ifConfirm" :loading="ifConfirm" size="small" loading-text="草稿保存中"
                                    type="primary" block @click="submitForm">保存草稿</van-button>
                            </div>
                        </div>
                    </div>

                </div>
                <van-loading v-if="showLoading" />
            </div>
        </div>

        <van-popup v-model="showSearch" round position="bottom">
            <div>
                <van-cell title="往来单位" :value="searchData.S_ClientName" is-link @click="openScreen(-1,10)">
                </van-cell>
            </div>
            <div class="btn-padding">
                <van-button type="primary" block style="border-radius: 0;" @click="searchList">查询</van-button>
            </div>
        </van-popup>

        <van-popup v-model="isShowFinal" round position="bottom">
            <div style="overflow-y: auto;max-height:350px;">
                <van-cell v-for="(row,index) in checkArray">
                    <div slot="title">
                        <div class="row-name">{{row.ProductName}}</div>
                        <van-stepper v-model="row.num" min="0" :max="row.BNum"></van-stepper>
                    </div>
                    <div slot="right-icon" @click="deleteRow(row,index)">
                        <van-icon name="delete" color="#cd1b21" size="20" style="vertical-align: middle;">
                        </van-icon>
                    </div>
                </van-cell>

            </div>
        </van-popup>

        <van-action-sheet v-model="showAction" :actions="newList" @select="onSelectAction"></van-action-sheet>
        <van-dialog v-model="showRemark" close-on-click-overlay @confirm="dialogRemarkConfirm">
            <div style="padding-top:10px;">
                <van-field label="备注" v-model="dialogRemark" placeholder="请输入备注"></van-field>
            </div>
        </van-dialog>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        //$('.init-full').show();

        api.setScreenOrientation({
            orientation: 'landscape_left'
        })

        api.addEventListener({
            name: 'setOrientation'
        }, function (ret, err) {
            setTimeout(function () {
                api.setScreenOrientation({
                    orientation: 'landscape_left'
                })
            }, 500)

        });

        api.addEventListener({
            name: 'keyback'
        }, function (ret, err) {
            vm.onClickLeft();
        });

        api.addEventListener({
            name: 'refreshDataList'
        }, function (ret, err) {
            var dataList = ret.value.dataList;
            vm.dataList[vm.tabActive].node[selectCell[0]].node[selectCell[1]].node = dataList;

        })

        api.addEventListener({
            name: 'selectCarItem'
        }, function (ret, err) {
            var carRow = ret.value.carRow;
            vm.carArray = [{
                BNum: 1,
                CXName: carRow.FName,
                HJName: "XXX",
                HJ_CH: 1,
                HJ_LH: 1,
                CXPath: carRow.FLogo,
                node: []
            }]

        })

        api.addEventListener({
            name: 'updateCheckArray'
        }, function (ret, err) {
            var type = ret.value.type;
            var row = ret.value.row;
            if (type == 'add') {
                vm.checkArray.push(row)
            } else if (type == 'delete') {
                var newArray = [];
                for (var i in vm.checkArray) {
                    if (vm.checkArray[i].ProductCode != row.ProductCode) {
                        newArray.push(vm.checkArray[i])
                    }

                }
                vm.checkArray = newArray;

            }
        });

        api.addEventListener({
            name: 'selectRow'
        }, function (ret, err) {
            var selectType = ret.value.selectType;
            var type = ret.value.type;
            var row = ret.value.row;
            if (selectType == 10) {
                if (row) {
                    clientInfo = row;
                    vm.searchData.S_ClientName = row.name;
                    vm.searchData.S_ClientID = row.id;
                } else {
                    vm.searchData.S_ClientName = '';
                    vm.searchData.S_ClientID = 0;
                }
                vm.checkArray = [];

            }

        });

        var userInfo = FLD.getUserInfo();
        var clientInfo = api.pageParam.clientInfo;
        var selectCell = [-1, -1];

        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                showSearch: false,
                showSort: false,
                showAction: false,
                ifConfirm: false,
                isShowFinal: false,
                showRightPage: false,
                showRemark: false,
                dialogRemarkIndex: -1,
                emptyArray: [],
                systemType: api.systemType,
                tabActive: 0,
                dataList: [],
                newList: [],
                checkArray: [],
                carArray: [],
                deleteArray: [1],
                sortableDrag: '',
                dialogRemark: '',
                searchData: {
                    S_ClientID: 0,
                    S_ClientName: '',
                    S_BranchID: userInfo.S_BranchID,
                    S_Type: 1,
                    S_HJName: '',
                    S_HJCS: 0,
                    S_HJLS: 0
                },
                moveTime: ''

            },
            created: function () {
                if (clientInfo) {
                    this.searchData.S_ClientID = clientInfo.id;
                    this.searchData.S_ClientName = clientInfo.name;
                    this.getList();
                    this.getNewList();
                } else {
                    this.showSearch = true;
                }

                // this.getList();



                // this.dataList = [{ "HJName": "滤清器", "node": [{ "HJ_CH": 1, "node": [{ "BNum": 9, "CXName": "丰田", "HJName": "滤清器", "HJ_CH": 1, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/475/259.jpg" }, { "BNum": 23, "CXName": "本田", "HJName": "滤清器", "HJ_CH": 1, "HJ_LH": 2, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/710.jpg" }, { "BNum": 13, "CXName": "日产", "HJName": "滤清器", "HJ_CH": 1, "HJ_LH": 3, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/753.jpg" }, { "BNum": 5, "CXName": "马自达", "HJName": "滤清器", "HJ_CH": 1, "HJ_LH": 4, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/080/799.jpg" }] }, { "HJ_CH": 2, "node": [{ "BNum": 15, "CXName": "现代", "HJName": "滤清器", "HJ_CH": 2, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/762.jpg" }, { "BNum": 15, "CXName": "大众", "HJName": "滤清器", "HJ_CH": 2, "HJ_LH": 2, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/717.jpg" }, { "BNum": 3, "CXName": "标致", "HJName": "滤清器", "HJ_CH": 2, "HJ_LH": 3, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/700.jpg" }] }, { "HJ_CH": 3, "node": [{ "BNum": 10, "CXName": "别克", "HJName": "滤清器", "HJ_CH": 3, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/080/797.jpg" }, { "BNum": 5, "CXName": "福特", "HJName": "滤清器", "HJ_CH": 3, "HJ_LH": 2, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/475/140.jpg" }, { "BNum": 30, "CXName": "长城", "HJName": "滤清器", "HJ_CH": 3, "HJ_LH": 3, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/712.jpg" }] }, { "HJ_CH": 4, "node": [{ "BNum": 15, "CXName": "丰田", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/475/259.jpg" }, { "BNum": 5, "CXName": "本田", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 2, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/710.jpg" }, { "BNum": 5, "CXName": "日产", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 3, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/753.jpg" }, { "BNum": 7, "CXName": "三菱", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 4, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/080/802.jpg" }, { "BNum": 5, "CXName": "现代", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 5, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/762.jpg" }, { "BNum": 24, "CXName": "大众", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 6, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/717.jpg" }, { "BNum": 4, "CXName": "标致", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 7, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/700.jpg" }, { "BNum": 18, "CXName": "别克", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 8, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/080/797.jpg" }, { "BNum": 15, "CXName": "福特", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 9, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/475/140.jpg" }, { "BNum": 18, "CXName": "长安", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 10, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/473/143.jpg" }, { "BNum": 5, "CXName": "奇瑞", "HJName": "滤清器", "HJ_CH": 4, "HJ_LH": 11, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/818.jpg" }] }, { "HJ_CH": 5, "node": [{ "BNum": 4, "CXName": "丰田", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/475/259.jpg" }, { "BNum": 3, "CXName": "本田", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 2, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/710.jpg" }, { "BNum": 10, "CXName": "日产", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 3, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/753.jpg" }, { "BNum": 2, "CXName": "马自达", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 4, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/080/799.jpg" }, { "BNum": 7, "CXName": "现代", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 5, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/762.jpg" }, { "BNum": 13, "CXName": "大众", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 6, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/717.jpg" }, { "BNum": 1, "CXName": "标致", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 7, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/700.jpg" }, { "BNum": 4, "CXName": "别克", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 8, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/080/797.jpg" }, { "BNum": 5, "CXName": "福特", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 9, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/475/140.jpg" }, { "BNum": 13, "CXName": "奇瑞", "HJName": "滤清器", "HJ_CH": 5, "HJ_LH": 10, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/818.jpg" }] }] }, { "HJName": "刹车片", "node": [{ "HJ_CH": 1, "node": [{ "BNum": 8, "CXName": "大众", "HJName": "刹车片", "HJ_CH": 1, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/717.jpg" }, { "BNum": 6, "CXName": "奥迪", "HJName": "刹车片", "HJ_CH": 1, "HJ_LH": 2, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/678/586.jpg" }, { "BNum": 14, "CXName": "别克", "HJName": "刹车片", "HJ_CH": 1, "HJ_LH": 3, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/080/797.jpg" }] }, { "HJ_CH": 2, "node": [{ "BNum": 10, "CXName": "本田", "HJName": "刹车片", "HJ_CH": 2, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/710.jpg" }, { "BNum": 12, "CXName": "丰田", "HJName": "刹车片", "HJ_CH": 2, "HJ_LH": 2, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/475/259.jpg" }, { "BNum": 5, "CXName": "日产", "HJName": "刹车片", "HJ_CH": 2, "HJ_LH": 3, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/753.jpg" }, { "BNum": 5, "CXName": "马自达", "HJName": "刹车片", "HJ_CH": 2, "HJ_LH": 4, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/080/799.jpg" }] }, { "HJ_CH": 3, "node": [{ "BNum": 10, "CXName": "现代", "HJName": "刹车片", "HJ_CH": 3, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/762.jpg" }, { "BNum": 3, "CXName": "起亚", "HJName": "刹车片", "HJ_CH": 3, "HJ_LH": 2, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/750.jpg" }, { "BNum": 4, "CXName": "雪铁龙", "HJName": "刹车片", "HJ_CH": 3, "HJ_LH": 3, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/766.jpg" }, { "BNum": 5, "CXName": "三菱", "HJName": "刹车片", "HJ_CH": 3, "HJ_LH": 4, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/080/802.jpg" }] }, { "HJ_CH": 4, "node": [{ "BNum": 3, "CXName": "福特", "HJName": "刹车片", "HJ_CH": 4, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/475/140.jpg" }, { "BNum": 5, "CXName": "长城", "HJName": "刹车片", "HJ_CH": 4, "HJ_LH": 2, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/712.jpg" }, { "BNum": 5, "CXName": "荣威", "HJName": "刹车片", "HJ_CH": 4, "HJ_LH": 3, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/065/752.jpg" }] }] }]

                // this.carArray = [{ "BNum": 1, "CXName": "阿尔法罗密欧", "HJName": "滤清器", "HJ_CH": 1, "HJ_LH": 1, "CXPath": "//c1.51cjml.com/c3/autobrandlogo/000/892/377.jpg" }]
            },
            methods: {
                getTotalNum(row){
                    var t = 0;
                    for(var i in row.node){
                        t+=parseInt(row.node[i].BNum)
                    }
                    return t;
                },
                startMoveDraggable(evt) {
                    var that = this;
                    that.moveTime = new Date();
                },
                endMoveDraggable(evt) {
                    var that = this;
                    if (new Date().getTime() - that.moveTime.getTime() < 200) {

                        var row1 = that.dataList[that.tabActive];
                        var item = JSON.parse(JSON.stringify(evt.item._underlying_vm_));
                        for (var i in that.dataList[that.tabActive].node) {
                            for (var j in that.dataList[that.tabActive].node[i].node) {
                                if (that.dataList[that.tabActive].node[i].node[j].CXName == item.CXName) {
                                    if (JSON.stringify(that.dataList[that.tabActive].node[i].node[j].node) == JSON.stringify(item.node)) {
                                        var row2 = that.dataList[that.tabActive].node[i];
                                        var row3 = that.dataList[that.tabActive].node[i].node[j];
                                        var index2 = i;
                                        var index3 = j;
                                        that.intoDetail2(row3, row2, row1, index2, index3)
                                    }
                                }
                            }
                        }

                    }
                },
                MoveDraggable(evt) {

                },
                getRowTotal(row2) {
                    var total = 0;
                    for (var i in row2.node) {
                        for(var j in row2.node[i].node){
                            total += row2.node[i].node[j].BNum;
                        }
                        
                    }
                    return total;
                },
                setLongTabListen() {
                    var that = this;
                    $(".tab-row").unbind().on({
                        //手指开始按时设置定时器，超过500毫秒就执行longPress()
                        touchstart: function (e) {
                            timeOutEvent = setTimeout(function () {
                                timeOutEvent = 0;

                                var index = parseInt($(e.target).attr('index'))
                                var name = $(e.target).text();
                                that.changeTab(index)
                                if (api.systemType == 'ios') {
                                    api.notification({
                                        vibrate: [100]
                                    });
                                } else {
                                    api.notification({
                                        vibrate: [100, 100]
                                    });
                                }

                                that.$dialog.confirm({
                                    title: '提示',
                                    width: '320px',
                                    closeOnClickOverlay: true,
                                    message: '是否确认删除货架' + name + '?'
                                }).then(() => {

                                    var obj = {
                                        S_ClientID: that.searchData.S_ClientID,
                                        S_HJName: name
                                    }
                                    FLD.ajax('AP_HJDelDNB', obj, function (res) {
                                        layer.open({
                                            content: '删除成功',
                                            skin: 'msg',
                                            time: 2
                                        });
                                        that.dataList.splice(index, 1);
                                    })
                                }).catch(() => {

                                });



                            }, 500);
                            e.preventDefault();
                        },
                        //如果手指滑动只是说明用户不想长按只想滑动，所以要取消定时器,并还原，
                        //如果不还原的话，返回的定时器的值都会是不同的
                        // touchmove: function (e) {



                        //     clearTimeout(timeOutEvent);
                        //     timeOutEvent = 0;
                        // },
                        //长按没有超过500毫秒，手指离开，执行点击事件，取消定时器
                        touchend: function (e) {
                            clearTimeout(timeOutEvent);
                            if (timeOutEvent != 0) {
                                //执行点击事件的行为
                                var index = parseInt($(e.target).attr('index'));
                                that.changeTab(index)
                            }
                            return false;
                        }
                    })
                },
                changeTab(index) {
                    var that = this;
                    that.tabActive = index;
                },
                addNew() {
                    api.openWin({
                        name: 'vehicleType',
                        url: 'vehicleType.html',
                        reload: true,
                        slidBackEnabled: false
                    })
                },
                addNewHJ() {
                    var that = this;
                    if (!that.searchData.S_ClientID) {
                        layer.open({
                            content: '请先选择往来单位',
                            skin: 'msg',
                            time: 2
                        });
                        return false;
                    }
                    if (!that.newList.length) {
                        layer.open({
                            content: '未查询到可供选择的货架',
                            skin: 'msg',
                            time: 2
                        });
                        return false;
                    }
                    that.showAction = true;
                },
                onSelectAction(item, index, isRepeat) {
                    var that = this;
                    var copyData = JSON.parse(JSON.stringify(item));
                    that.showAction = false;
                    var x = 0;
                    if (isRepeat) {
                        x = 1;
                    }
                    for (var i in that.dataList) {

                        if (that.dataList[i].HJName == copyData.HJName) {
                            x = 1;
                            var splitData = copyData.HJName.split('-');
                            if (splitData.length > 1) {
                                copyData.HJName = splitData[0] + '-' + (parseInt(splitData[1]) + 1)
                                that.onSelectAction(copyData, 0, 1);
                                return;
                            } else {
                                copyData.HJName = copyData.HJName + '-1';
                                that.dataList.push(copyData);
                            }


                        }
                    }
                    if (x == 0) {
                        that.dataList.push(copyData);
                    }
                    that.tabActive = that.dataList.length - 1;
                    that.showSort = true;
                    that.$nextTick(function () {
                        that.setLongTabListen();
                    })
                },
                getNewList() {
                    var that = this;
                    var obj = {
                        S_ClientID: that.searchData.S_ClientID,
                        S_ClientName: that.searchData.S_ClientName,
                        S_BranchID: userInfo.S_BranchID,
                        S_Type: 3,
                        S_HJName: '',
                        S_HJCS: 0,
                        S_HJLS: 0
                    }
                    FLD.ajax('AP_HJCXJKA', obj, function (res) {
                        if (res.ds[0].status && res.ds[0].status == 500) {
                            layer.open({
                                content: res.ds[0].msg,
                                skin: 'msg',
                                time: 2
                            });
                            that.dataList = [];
                            return false;
                        }
                        var dataList = [];
                        for (var i in res.ds) {
                            var f_node = [];
                            for (var j in res.ds1) {
                                if (res.ds[i].HJName == res.ds1[j].HJName && res.ds[i].HJ_CH == res.ds1[j].HJ_CH && res.ds[i].HJ_LH == res.ds1[j].HJ_LH && res.ds[i].CXName == res.ds1[j].CXName) {
                                    f_node.push(res.ds1[j])
                                }
                            }
                            res.ds[i].node = f_node;
                            var x = 0;
                            for (var j in dataList) {
                                if (res.ds[i].HJName == dataList[j].HJName) {
                                    x = 1;
                                    var y = 0;
                                    for (var l in dataList[j].node) {
                                        if (res.ds[i].HJ_CH == dataList[j].node[l].HJ_CH) {
                                            y = 1;
                                            dataList[j].node[l].node.push(res.ds[i]);
                                        }
                                    }
                                    if (y == 0) {
                                        dataList[j].node.push({
                                            HJ_CH: res.ds[i].HJ_CH,
                                            Explain: '',
                                            node: [res.ds[i]]
                                        })
                                    }
                                }
                            }
                            if (x == 0) {
                                dataList.push({
                                    name: res.ds[i].HJName,
                                    HJName: res.ds[i].HJName,
                                    node: [{
                                        HJ_CH: res.ds[i].HJ_CH,
                                        Explain: '',
                                        node: [res.ds[i]]
                                    }]
                                })
                            }
                        }
                        for (var i in dataList) {
                            var newNode = [];

                            var max_m = 4;
                            if (dataList[i].HJName.indexOf('滤') > -1) {
                                max_m = 5;
                            }
                            for (var m = 1; m <= max_m; m++) {
                                var y = 0;
                                for (var j in dataList[i].node) {
                                    if (dataList[i].node[j].HJ_CH == m) {
                                        y = 1;
                                        newNode.push({
                                            HJ_CH: m,
                                            Explain: '',
                                            node: dataList[i].node[j].node
                                        });
                                    }
                                }
                                if (y == 0) {
                                    newNode.push({
                                        HJ_CH: m,
                                        Explain: '',
                                        node: []
                                    });
                                }
                            }
                            dataList[i].node = newNode;
                        }
                        that.newList = dataList;
                    })
                },
                getList() {
                    var that = this;
                    that.showLoading = true;
                    FLD.ajax('AP_HJCXJKA', that.searchData, function (res) {
                        that.showLoading = false;
                        if (!res.ds.length) {
                            layer.open({
                                content: '未查询到货架信息',
                                skin: 'msg',
                                time: 2
                            });
                            that.dataList = [];
                            return false;
                        }
                        if (res.ds[0].status && res.ds[0].status == 500) {
                            layer.open({
                                content: res.ds[0].msg,
                                skin: 'msg',
                                time: 2
                            });
                            that.dataList = [];
                            return false;
                        }
                        var dataList = [];
                        for (var i in res.ds) {
                            var f_node = [];
                            for (var j in res.ds1) {
                                if (res.ds[i].HJName == res.ds1[j].HJName && res.ds[i].HJ_CH == res.ds1[j].HJ_CH && res.ds[i].HJ_LH == res.ds1[j].HJ_LH && res.ds[i].CXName == res.ds1[j].CXName) {
                                    f_node.push(res.ds1[j])
                                }
                            }
                            res.ds[i].node = f_node;
                            var x = 0;
                            for (var j in dataList) {
                                if (res.ds[i].HJName == dataList[j].HJName) {
                                    x = 1;
                                    var y = 0;
                                    for (var l in dataList[j].node) {
                                        if (res.ds[i].HJ_CH == dataList[j].node[l].HJ_CH) {
                                            y = 1;
                                            dataList[j].node[l].node.push(res.ds[i]);
                                        }
                                    }
                                    if (y == 0) {
                                        dataList[j].node.push({
                                            HJ_CH: res.ds[i].HJ_CH,
                                            Explain: res.ds[i].Explain,
                                            node: [res.ds[i]]
                                        })
                                    }
                                }
                            }
                            if (x == 0) {
                                dataList.push({
                                    HJName: res.ds[i].HJName,
                                    node: [{
                                        HJ_CH: res.ds[i].HJ_CH,
                                        Explain: res.ds[i].Explain,
                                        node: [res.ds[i]]
                                    }]
                                })
                            }
                        }
                        for (var i in dataList) {
                            var newNode = [];

                            var max_m = 4;
                            if (dataList[i].HJName.indexOf('滤') > -1) {
                                max_m = 5;
                            }
                            for (var m = 1; m <= max_m; m++) {
                                var y = 0;
                                for (var j in dataList[i].node) {
                                    if (dataList[i].node[j].HJ_CH == m) {
                                        y = 1;
                                        newNode.push({
                                            HJ_CH: m,
                                            Explain: dataList[i].node[j].Explain,
                                            node: dataList[i].node[j].node
                                        });
                                    }
                                }
                                if (y == 0) {
                                    newNode.push({
                                        HJ_CH: m,
                                        Explain: '',
                                        node: []
                                    });
                                }
                            }

                            dataList[i].node = newNode;

                        }
                        // console.log(JSON.stringify(dataList))
                        that.dataList = dataList;

                        that.$nextTick(function () {
                            that.setLongTabListen()
                        })


                    })
                },
                searchList() {
                    var that = this;
                    that.showSearch = false;
                    that.getList();
                    that.getNewList();
                },
                openCheckedList() {
                    var that = this;
                    if (that.checkArray.length) {
                        that.isShowFinal = true;
                    }

                },
                deleteRow(row, index) {
                    var that = this;
                    that.checkArray.splice(index, 1);
                    if (that.checkArray.length == 0) {
                        that.isShowFinal = false;
                    }
                },
                getBHCount() {
                    var that = this;
                    var totalCount = 0;
                    for (var i in that.checkArray) {
                        totalCount += parseInt(that.checkArray[i].num);
                    }
                    return totalCount;
                },
                getTotal(row2) {
                    var num = 0;
                    for (var i in row2.node) {
                        num += row2.node[i].BNum;
                    }
                    return num;
                },
                intoDetail1(row2, row1, index2) {
                    var that = this;
                    if (that.showSort) {
                        that.dialogRemark = row2.Explain;
                        that.dialogRemarkIndex = index2;
                        that.showRemark = true;
                    } else {
                        var dataList = [];
                        for (var i in row2.node) {
                            row2.node[i].HJ_CH = index2;
                            row2.node[i].HJ_LH = parseInt(i) + 1;
                            for (var j in row2.node[i].node) {
                                row2.node[i].node[j].HJ_CH = row2.node[i].HJ_CH;
                                row2.node[i].node[j].HJ_LH = row2.node[i].HJ_LH;
                            }
                            dataList = dataList.concat(row2.node[i].node);
                        }

                        api.openWin({
                            name: '货架明细',
                            url: 'goodsShelvesDetail.html',
                            reload: true,
                            slidBackEnabled: false,
                            pageParam: {
                                // filterData: obj,
                                dataList: dataList,
                                checkArray: that.checkArray,
                                type: 2,
                                title: row1.HJName + (index2 + 1) + '层'
                            }
                        })
                    }

                },
                dialogRemarkConfirm() {
                    var that = this;
                    that.dataList[that.tabActive].node[that.dialogRemarkIndex].Explain = that.dialogRemark;
                    that.showRemark = false;
                },
                intoDetail2(row3, row2, row1, index2, index3) {
                    var that = this;
                    selectCell = [index2, index3];
                    for (var i in row3.node) {
                        row3.node[i].HJ_CH = index2 + 1;
                        row3.node[i].HJ_LH = index3 + 1;
                    }
                    api.openWin({
                        name: '货架明细',
                        url: 'goodsShelvesDetail.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: {
                            // filterData: obj,
                            dataList: row3.node,
                            checkArray: that.checkArray,
                            type: that.showSort ? 1 : 2,
                            title: row3.CXName,
                            c: row2.HJ_CH,
                            l: row3.HJ_LH
                        }
                    })
                },
                openScreen(type, index) {
                    var that = this;
                    var obj = {
                        S_Type: index,
                        S_Cont: '',
                        S_BranchID: userInfo.S_BranchID,
                        S_SXZ: '',
                        S_StockID: userInfo.S_StockID,
                        S_CargoID: userInfo.S_CargoID,
                        S_BarCode: '',
                        S_PriceN: 0,
                        S_ProductID: 0
                    }

                    api.openWin({
                        name: '筛选' + index,
                        url: 'common/baseScreen.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: {
                            filterData: obj,
                            type: type,
                            allowClear: true
                        }
                    })

                },
                toggleSort() {
                    var that = this;
                    if (that.showSort) {
                        var S_HJZH = [];
                        for (var i in that.dataList) {
                            if (i == that.tabActive) {
                                for (var j in that.dataList[i].node) {
                                    for (var l in that.dataList[i].node[j].node) {
                                        for (var m in that.dataList[i].node[j].node[l].node) {
                                            var detailArray = [];
                                            detailArray.push(
                                                '\'' + that.dataList[i].HJName + '\'',
                                                '\'' + that.dataList[i].node[j].HJ_CH + '\'',
                                                '\'' + (parseInt(l) + 1) + '\'',
                                                '\'' + that.dataList[i].node[j].node[l].node[m].CXName + '\'',
                                                '\'' + that.dataList[i].node[j].node[l].node[m].ProductID + '\'',
                                                '\'' + that.dataList[i].node[j].node[l].node[m].BNum + '\'',
                                                '\'' + (that.dataList[i].node[j].Explain || '') + '\''
                                            )
                                            S_HJZH.push(detailArray.join(','))
                                        }
                                    }
                                }
                            }

                        }
                        var obj = {
                            S_BranchID: userInfo.S_BranchID,
                            S_ClientID: that.searchData.S_ClientID,
                            S_HJZH: S_HJZH.join('|')
                        }
                        FLD.ajax('AP_HJBJTJN', obj, function (res) {
                            if (res.ds[0].status == 200) {
                                that.showSort = false;
                                layer.open({
                                    content: '保存成功',
                                    skin: 'msg',
                                    time: 2
                                });
                            } else {
                                layer.open({
                                    content: res.ds[0].msg,
                                    skin: 'msg',
                                    time: 2
                                });
                            }
                        })
                    } else {
                        that.showSort = true;
                    }
                },
                submitForm() {
                    var that = this;

                    that.$dialog.confirm({
                        title: '提示',
                        closeOnClickOverlay: true,
                        message: '是否确认保存草稿'
                    }).then(() => {

                        if (!that.checkArray.length) {
                            layer.open({
                                content: '请选择需要补货的商品',
                                skin: 'msg',
                                time: 2
                            });
                            return false;
                        }

                        that.ifConfirm = true;
                        var formDetailData = [];
                        var repeatSelectArray = function (x) {
                            if (x >= that.checkArray.length) {

                                var formData = {
                                    ClientID: clientInfo.id,
                                    ClientName: clientInfo.name,
                                    RecMoney: '',
                                    PerMoney: '',
                                    BranchID: userInfo.S_BranchID,
                                    BranchName: userInfo.S_BranchName,
                                    EmplID: userInfo.S_EmplID || clientInfo.S_EmplID,
                                    EmplName: userInfo.S_EmplName || clientInfo.S_EmplName,
                                    ClassID: userInfo.S_ClassID || clientInfo.S_ClassID,
                                    ClassName: userInfo.S_ClassName || clientInfo.S_ClassName,
                                    StockID: userInfo.S_StockID,
                                    StockName: userInfo.S_StockName,
                                    CargoID: userInfo.S_CargoID,
                                    CargoName: userInfo.S_CargoName,
                                    ProjectID: userInfo.S_ProjectID,
                                    ProjectName: userInfo.S_ProjectName,
                                    VIPCardID: 0,
                                    VIPName: '',
                                    PriceN: clientInfo.S_PriceN,
                                    PriceNName: clientInfo.S_PriceNName,
                                    Explain: '',
                                    BType: 'BH',
                                    BTypeName: '补货'
                                }


                                // var jsonstr1 = JSON.stringify(formData).replace(/\'/g, '\'\'')
                                // var jsonstr2 = JSON.stringify(formDetailData).replace(/\'/g, '\'\'')
                                // var sql = "insert into Draft (JSONStr1,JSONStr2,CreateTime,UpdateTime,Type,Status) values ('" + jsonstr1 + "','" + jsonstr2 + "','" + FLD.getFormatDate() + "',null,101,null)"
                                // DB.executeSql(sql, function () {
                                //     that.ifConfirm = false;
                                //     that.checkArray = [];
                                //     layer.open({
                                //         content: '保存成功',
                                //         skin: 'msg',
                                //         time: 2,
                                //         end: function () {
                                //             api.setScreenOrientation({
                                //                 orientation: 'portrait_up'
                                //             })
                                //             api.openWin({
                                //                 name: 'draft',
                                //                 url: 'draft.html',
                                //                 reload: true,
                                //                 slidBackEnabled: false,
                                //                 pageParam: {
                                //                     tabActive: 0
                                //                 }
                                //             })
                                //         }
                                //     });


                                // })



                                var S_STRZB = [];
                                for (var i in formData) {
                                    if (i == 'RecMoney' || i == 'PerMoney') {
                                        S_STRZB.push('\'' + (formData[i] || 0) + '\'');
                                    } else {
                                        S_STRZB.push('\'' + formData[i] + '\'');
                                    }

                                }
                                var S_STRDe = [];
                                for (var i in formDetailData) {
                                    var detailArray = [];
                                    detailArray.push(
                                        '\'' + formDetailData[i].id + '\'',
                                        '\'' + formDetailData[i].name + '\'',
                                        '\'' + formDetailData[i].code + '\'',
                                        '\'' + formDetailData[i].spec + '\'',
                                        '\'' + formDetailData[i].num + '\'',
                                        '\'' + formDetailData[i].price + '\'',
                                        '\'' + (formDetailData[i].num * formDetailData[i].price).toFixed(2) + '\'',
                                        '\'' + formDetailData[i].stockID + '\'',
                                        '\'' + formDetailData[i].stockName + '\'',
                                        '\'' + formDetailData[i].cargoID + '\'',
                                        '\'' + formDetailData[i].cargoName + '\''
                                    )
                                    S_STRDe.push(detailArray.join(','))
                                }

                                var obj = {
                                    S_BillType: 101,
                                    S_STRZB: S_STRZB.join(),
                                    S_STRDe: S_STRDe.join('|')
                                }
                                that.ifConfirm = true;



                                FLD.ajax('APP_XSCKCGTJ', obj, function (res) {
                                    that.ifConfirm = false;
                                    if (res.ds[0].status == 200) {
                                        that.checkArray = [];
                                        layer.open({
                                            content: '保存成功',
                                            skin: 'msg',
                                            time: 2,
                                            end: function () {
                                                api.setScreenOrientation({
                                                    orientation: 'portrait_up'
                                                })
                                                api.openWin({
                                                    name: '历史单据',
                                                    url: 'common/historicalDocuments.html',
                                                    reload: true,
                                                    slidBackEnabled: false,
                                                    pageParam: {
                                                        type: 101,
                                                        tabActive: 0
                                                    }
                                                })
                                            }
                                        });
                                    } else {
                                        layer.open({
                                            content: res.ds[0].msg,
                                            skin: 'msg',
                                            time: 2
                                        });
                                    }
                                })
                            } else {
                                var obj = {
                                    S_Type: 60,
                                    S_Cont: '',
                                    S_BranchID: userInfo.S_BranchID,
                                    S_SXZ: '',
                                    S_StockID: userInfo.S_StockID,
                                    S_CargoID: userInfo.S_CargoID,
                                    S_BarCode: '',
                                    S_PriceN: clientInfo.S_PriceN,
                                    S_ProductID: that.checkArray[x].ProductID
                                }
                                FLD.ajax('AP_BasList', obj, function (res) {
                                    var row = res.ds[0];
                                    formDetailData.push({
                                        showDetail: false,
                                        hasEdit: false,
                                        id: row.id,
                                        detailID: 0,
                                        name: row.name,
                                        code: row.code,
                                        spec: row.Spec,
                                        num: that.checkArray[x].num,
                                        price: row.BPrice || 0,
                                        stockID: userInfo.S_StockID,
                                        stockName: userInfo.S_StockName,
                                        cargoID: userInfo.S_CargoID,
                                        cargoName: userInfo.S_CargoName,
                                        stockNum: row.StockNum,
                                        unit: row.Unit
                                    })
                                    x++;
                                    repeatSelectArray(x);
                                })

                            }
                        }
                        repeatSelectArray(0);

                    }).catch(() => {

                    });



                },
                onClickLeft() {
                    var that = this;
                    if (that.showSort) {
                        that.toggleSort();
                    }
                    api.setScreenOrientation({
                        orientation: 'portrait_up'
                    })
                    api.closeWin();
                }
            }
        })
    };
</script>

</html>